import numpy as np
import pandas as pd
import matplotlib.pyplot as plt  # 画图的画笔

data = pd.read_excel("./体测分数_男生.xls")

cond = data.男1000米跑 > 0
p = pd.cut(data[cond].男1000米跑, bins=3, labels=['快', '中', '慢'], right=True).value_counts()
p1 = pd.cut(data.男引体分数, bins=3, labels=['快', '中', '慢'], right=True).value_counts()

plt.figure(figsize=(9, 9))
m1 = plt.pie(p,
             labels=['Quick', 'Normal', 'Slow'],
             radius=1,
             autopct='%0.2f%%',
             pctdistance=0.85,
             wedgeprops={'linewidth': 5,  # 间隔的宽度
                         'width': 0.3,  # 饼图的宽度
                         'edgecolor': 'white'},  # 间隔的颜色
             )

m2 = plt.pie(p1,
             labels=['Strong', 'Common', 'Weak'],
             radius=0.5,
             autopct='%0.2f%%',
             wedgeprops={'linewidth': 5,  # 间隔的宽度
                         'width': 0.3,  # 饼图的宽度
                         'edgecolor': 'white'},  # 间隔的颜色
             )

plt.legend(['Quick', 'Normal', 'Slow', 'Strong', 'Common', 'Weak'], title='Category')
plt.show()
